package com.myhome.money.spring.lifecycle.listenter;

import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author Rod
 */
@Component
public class MyAnnotationListener {
    @EventListener
    public void listener1(MyEvent event) {
        event.myEventTest();
        System.out.println("注解监听器1");
    }

    @EventListener
    @Async
    public void listener2(MyEvent event) {
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        event.myEventTest();
        System.out.println("注解监听器2");
    }

}
